/**
 * 
 */
package fr.univ_tln.inf9.exaplanning.controleur.salle;

import java.util.List;

import fr.univ_tln.inf9.exaplanning.api.salle.Building;
import fr.univ_tln.inf9.exaplanning.api.salle.Room;
import fr.univ_tln.inf9.exaplanning.gui.salle.JFrameListRoom;


/**
 * @author pivi
 *
 */
public class BuildingController {

	/**
	 * Ici les déclarations des frames de la gui
	 */

	public BuildingView listView = null;
	
	
	private Building b = null;
	
	public BuildingController (Building b){
		this.b = b;
		
		listView = new JFrameListRoom(this, b.getRooms(),b.getName());
		
		
		addListenersToPosition_x();
		addListenersToPosition_y();
		addToListRoomListener();
		
		}


	private void addToListRoomListener() {
		b.AddListRoomListener(listView);
		
	}


	private void addListenersToPosition_y() {
		b.addPosition_yListener(listView);
		
	}



	private void addListenersToPosition_x() {
		b.addPosition_xListener(listView);
		
	}

	public void displayViews(){
		listView.display();
	}
	
	public void closeViews(){
		listView.close();
	}
	
	public void notifyPosition_xChanged(float pos){
		b.setPosition_x(pos);
	}
	
	public void notifyPosition_yChanged(float pos){
		b.setPosition_y(pos);
	}
	
	public void notifyListRoomChanged(List<String> lroom) {
		b.setRooms(lroom);
	}
	
	
	public void notifyRoomAddedToList(Room r) {
		b.add(r);
	}
	
	public void notifyRoomRemovedToList(String r) {
		b.remove(r);
	}
	
}
